package com.tzl.config;

import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
	@Bean
	public Docket docketApiInfo(){
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(apiInfo())
				.groupName("api组")
				.select()
				.paths(Predicates.and(PathSelectors.regex("/api/.*")))
				.build();
	}
	@Bean
	public Docket docketAdminInfo(){
		return new Docket(DocumentationType.SWAGGER_2)
				.apiInfo(adminInfo())
				.groupName("admin组")
				.select()
				.paths(Predicates.and(PathSelectors.regex("/admin/.*")))
				.build();
	}
	private ApiInfo adminInfo() {
		return new ApiInfoBuilder()
				.version("1.0.0")
				.title("后台管理系统-API文档")
				.description("后台管理员接口文档")
				.contact(new Contact("合众后台管理员", "http://hzitxx.com", "2324250597@qq.com"))
				.build();
	}
	private ApiInfo apiInfo() {
		return new ApiInfoBuilder()
				.version("1.0.0")
				.title("后台管理系统-API文档")
				.description("普通用户接口文档")
				.contact(new Contact("后台普通用户", "http://hzitxx.com", "2324250597@qq.com"))
				.build();
	}
}
